<template>
	<view class="u-page">
		<u-empty v-if="orders.length==0" text="明天没有订单!" mode="search" marginTop="50"></u-empty>
		<block v-else>
			<view style="padding:10rpx;">
				<orderlist :orders="orders" :init_status="1" day="tomorrow" v-on:updateList="updateList"/>
			</view>			
		</block>
		<driverbar name="tomorrow"/>
	</view>
</template>
<script>
	import Orderlist from './orderlist.vue';
	import Driverbar from './driverbar.vue';
	import {methods} from '@/utils/methods.js';
	let interval;
	export default {
		components: {
			Orderlist,Driverbar
		},
		data() {
			return {
				latitude: '26.6015',
				longitude: '106.62254',
				orders: []	
			}
		},
		onLoad(options) {
			
		},
		onShow() {
			let that=this;
			uni.getLocation({
				type: 'gcj02',
				success(res) {
					that.longitude = res.longitude;
					that.latitude = res.latitude;
					that.getOrderList();
				},
				fail(e) {
					that.longitude = 106.62254;
					that.latitude = 26.6015;
					that.getOrderList();
				}
			});
		},
		methods: {
			...methods,
			updateList:function(){
				this.getOrderList();
			},
			getOrderList() {
				this.$get('driver/order',{
					type:'tomorrow',
					latitude: this.latitude,
					longitude: this.longitude
				}).then(info=>{
					this.orders = info;
				});
			}			
		}
	}
</script>
<style scoped lang="scss">
	
</style>
